/**
 * $Revision: 1.0 $ $Author: Eric Yang $ $Date: Aug 6, 2009 1:04:47 AM $ Author: Eric Yang Date : Aug 6, 2009 1:04:47 AM
 */
package com.gooex.service.organization;

import java.util.List;

import com.gooex.domain.organization.Authority;
import com.gooex.domain.organization.AuthorizedObject;
import com.gooex.service.organization.exception.AuthoritionException;

/**
 * @author Eric Yang
 * @version 1.0
 */
public interface IAuthorityManager {
	/** TODO comment */
	public Authority getAuthority(String id);

	/** TODO comment */
	public Authority getAuthorityByName(String name);

	/** TODO comment */
	public void saveAuthority(Authority authority);

	/** TODO comment */
	public void removeAuthority(Authority authority) throws AuthoritionException;

	/** TODO comment */
	public void saveAuthorizedObject(AuthorizedObject authorizedObject);

	/** TODO comment */
	public boolean isSystemAuthority(Authority authority);

	/** TODO comment */
	public boolean isSystemAuthorizedObject(AuthorizedObject authorizedObject);

	/**
	 * Judge whether the entity has the authority.<br>
	 * If the entity is a super user initialized by system,it always return true.<br>
	 * Super user was set in configration file.
	 * 
	 * @param authorizedObject
	 * @param authority
	 */
	public boolean hasAuthority(AuthorizedObject authorizedObject, Authority authority);

	/**
	 * If the grantor object has the authority ,the grant the authority to the target and return true.<br>
	 * otherwise return false.<br>
	 * 
	 * @param target
	 * @param grantor
	 * @param authority
	 */
	public boolean authorize(AuthorizedObject target, AuthorizedObject grantor, Authority authority);

	/** TODO comment */
	public List<Authority> getAuthorities();

}
